package 力扣._377_组合总和4;

import java.util.Arrays;

public class Solution {
    public int combinationSum4(int[] nums, int target) {
        //强调不同元素间的顺序——》排列数——》先容量再背包
        int[] dp = new int[target + 1];
        dp[0] = 1;
        for (int j = 0; j <= target; j++) { //容量
            for (int i = 0; i < nums.length; i++) { //物品
                if (j - nums[i] >= 0)
                    dp[j] += dp[j - nums[i]];
            }
        }
//        System.out.println(Arrays.toString(dp));
        return dp[target];

    }

    public static void main(String[] args) {
        int i = new Solution().combinationSum4(new int[]{1, 2, 5}, 5);
        System.out.println(i);
    }
}
